<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>订单数据</title>
		<link rel="stylesheet" href="css/_all-skins.min.css" />
		<link rel="stylesheet" href="css/AdminLTE.min.css" />
		<link rel="stylesheet" href="css/bootstrap.min.css" />
		<link rel="stylesheet" href="css/daterangepicker.css" />
		<link rel="stylesheet" type="text/css" href="css/bootstrap-datepicker.min.css"/>
		<link rel="stylesheet" href="css/select2.min.css" />
		<link rel="stylesheet" href="css/font-awesome.min.css" />
		<link rel="stylesheet" href="css/echart.css" />
		<link rel="stylesheet" type="text/css" href="css/layer.css"/>
		<link rel="stylesheet" href="css/order_data.css" />
	</head>
	<style>
		
	</style>
	<body class="hold-transition skin-blue sidebar-mini fixed">
<div class="wrapper">

   <header class="main-header">
    <!-- Logo -->
    <a href="index2.html" class="logo">
      <!-- mini logo for sidebar mini 50x50 pixels -->
   
      <!-- logo for regular state and mobile devices -->
      <span class="logo-lg"><b>衣当先</b>CRM</span>
    </a>
    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top">
      <!-- Sidebar toggle button-->
      <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
        <span class="sr-only">Toggle navigation</span>
      </a>

      <div class="navbar-custom-menu">
        <ul class="nav navbar-nav">
          <li class="dropdown user user-menu">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
            	
              <img src="img/user2-160x160.jpg" class="user-image" alt="User Image">
              <span class="hidden-xs  manger-name">Amy</span>
               
            	 <span class="change_password" style="font-size: 12px;margin-left: 40px;">修改密码</span>
            	 <span class="exit_login" style="font-size: 12px;">退出登录</span>
            </a>
            
          </li>
        </ul>
      </div>
    </nav>
  </header>
  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar">
    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
      <!-- Sidebar user panel -->
      <div class="user-panel">
        <div class="pull-left image">
          <img src="img/user2-160x160.jpg" class="img-circle">
        </div>
        <div class="pull-left info">
          <p class="manger-name">Amy</p>
          <a href="#"><i class="fa fa-circle text-success"></i> 在线</a>
        </div>
      </div>
      <!-- search form -->
      <form action="#" method="get" class="sidebar-form">
        <div class="input-group">
          <input type="text" name="q" class="form-control" placeholder="Search...">
          <span class="input-group-btn">
                <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
                </button>
              </span>
        </div>
      </form>
      <!-- /.search form -->
      <!-- sidebar menu: : style can be found in sidebar.less -->
      <ul class="sidebar-menu" data-widget="tree">
        <li class="header">功能目录</li>
        
        <li class=" treeview">
          <a href="#">
            <i class="fa fa-dashboard"></i> <span>系统首页</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li class=""><a href="index.html"><i class="fa fa-circle-o"></i> 首页总览</a></li>
            <li><a href="login_log.html"><i class="fa fa-circle-o"></i> 登录日志</a></li>
              <li><a href="id_manager.html"><i class="fa fa-circle-o"></i> 账号管理</a></li>
          </ul>
        </li>
      
        <li class="treeview">
          <a href="#">
            <i class="fa fa-laptop"></i>
            <span>商品管理</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
           <ul class="treeview-menu">
            <li><a href="product_list.html"><i class="fa fa-circle-o"></i> 商品列表</a></li>
            <li><a href="new_product.html"><i class="fa fa-circle-o"></i> 新增商品</a></li>
            <li><a href="product_kind.html"><i class="fa fa-circle-o"></i> 商品分类</a></li>
            <li><a href="product_confirm.html"><i class="fa fa-circle-o"></i> 商品审核</a></li>
             <li><a href="product_income.html"><i class="fa fa-circle-o"></i> 商品回收</a></li>
          </ul>
        </li>

        <li class="treeview">
          <a href="#">
            <i class="fa fa-edit"></i> <span>订单管理</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li><a href="hire_order.html"><i class="fa fa-circle-o"></i> 租赁订单</a></li>
            <li><a href="pay_order.html"><i class="fa fa-circle-o"></i> 支付订单</a></li>
            <li><a href="operate_log.html"><i class="fa fa-circle-o"></i> 订单日志</a></li>
          </ul>
        </li>          
        <li class="treeview">
          <a href="#">
            <i class="fa fa-pie-chart"></i>
            <span>用户管理</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li><a href="user_list.html"><i class="fa fa-circle-o"></i> 用户列表</a></li>
            <li><a href="discounts.html"><i class="fa fa-circle-o"></i> 优惠卷中心</a></li>
          </ul>
        </li>
        <li class="active treeview">
          <a href="#">
            <i class="fa fa-pie-chart"></i>
            <span>数据管理</span>
            <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
          </a>
          <ul class="treeview-menu">
            <li><a href="all_data.html"><i class="fa fa-circle-o"></i> 数据日报</a></li>
            <li><a href="product_data.html"><i class="fa fa-circle-o"></i> 商品数据</a></li>
            <li class="active"><a href="order_data.html"><i class="fa fa-circle-o"></i>订单数据</a></li>
            <li><a href="user_data.html"><i class="fa fa-circle-o"></i> 用户数据</a></li>
           <li><a href="income_data.html"><i class="fa fa-circle-o"></i> 收入数据</a></li>
          </ul>
        </li>
        <li>
          <a href="advice.html">
            <i class="fa fa-files-o"></i> <span>反馈建议</span>
          </a>
        </li>
         <li>
          <a href="w_internet.html">
            <i class="fa fa-book"></i> <span>物联网订单</span>
          </a>
        </li>
      </ul>
    </section>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    

    <!-- Main content -->
           
    
    <section class="content" >
       <div class="row">
       	 <div class="col-lg-1"></div>
       	 <div class="col-lg-10" style="padding: 0;">
       	 	
       	 	<div class="order_status">
       	 			<div>
       	 				<span>新增订单</span><br />
       	 				<label>0</label>
       	 			</div>
       	 			
       	 			<div>
       	 				<span>待发货订单</span><br />
       	 				<label>0</label>
       	 			</div>
       	 			
       	 			<div>
       	 				<span>归还订单</span><br />
       	 				<label>0</label>
       	 			</div>
       	 			
       	 			<div>
       	 				<span>本周订单</span><br />
       	 				<label>0</label>
       	 			</div>
       	 			<div>
       	 				<span>本月订单</span><br />
       	 				<label>0</label>
       	 			</div>
       	 	</div>
       	 </div>
       </div>
	   <div class="row">
       	 <div class="col-lg-1"></div>
       	 <div class="col-lg-10 box1">
       	 	<div class="box_title">
       	 		<h4>七日订单详情</h4>
       	 		<input type="text" placeholder="请选择时间" class="date_pick form-control " id="reservat" style="width: 200px;">
       	 		<input type="button" class="btn btn-default dayorder_search" value="筛选"/>
       	 	</div>
       	 	<div class=" row box1_lines">
       	 		<div class="col-lg-7 col-md-12 lines_item" id="my_chart2">
       	 		</div>
       	 		<div class="col-lg-5 col-md-12  lines_item ">
       	 			<div class="lines_table">
       	 				<table class="">
	       	 				<thead>
	       	 					<tr>
		       	 					<td>日期</td>
		       	 					<td>租赁订单</td>
		       	 				</tr>
	       	 				</thead>
	       	 				<tbody class="table_data"></tbody>
	       	 			</table>
       	 			</div>
       	 			
       	 			
       	 		</div>
       	 	</div>
       	 </div>
       </div>
       <div class="row" style="margin-top: 20px;">
       	 <div class="col-lg-1"></div>
       	 <div class="col-lg-10 box1">
       	 	<div class="box_title">
       	 		<h4>周订单对比</h4>
       	 		<input type="text" placeholder="请选择时间" class="date_pick form-control " id="reservat2" style="width: 200px;">
       	 		<input type="button" class="btn btn-default week_order" value="筛选"/>
       	 	</div>
       	 	<div class=" row box1_lines">
       	 		<div class="col-lg-7 col-md-12 lines_item" id="my_chart">
       	 		</div>
       	 		<div class="col-lg-5 col-md-12 lines_item bar_table">
       	 			<table style="color: #f56954;">
       	 				<tr>
       	 					<td>上周租赁订单:<span class="prev_hire">0</span></td>
       	 					<td rowspan="2" style="text-align: center;">
       	 							<img src="img/QQ图片20180729190220.png" width="100px" height="80px"/>
       	 					</td>
       	 					<td rowspan="2">增长率：<span class="hire_change">0</span></td>
       	 				</tr>
       	 				<tr>
       	 					<td>本周租赁订单:<span class="now_hire">0</span></td>
       	 				</tr>
       	 			</table>
       	 			<table style="color: #00a65a;">
       	 				<tr>
       	 					<td>上周支付订单:<span class="prev_pay">0</span></td>
       	 					<td rowspan="2" style="text-align: center;">
       	 							<img src="img/QQ图片20180729190220.png" width="100px" height="80px"/>
       	 					</td>
       	 					<td rowspan="2">增长率：<span class="pay_change">0</span></td>
       	 				</tr>
       	 				<tr>
       	 					<td>本周支付订单:<span class="now_pay">0</span></td>
       	 				</tr>
       	 			</table>
       	 		</div>
       	 	</div>
       	 </div>
       </div>
        <div class="row" style="margin-top: 20px;">
       	 <div class="col-lg-1"></div>
       	 <div class="col-lg-10 box1">
       	 	<div class="box_title">
       	 		<h4>订单转化率</h4>
       	 		<input type="text" placeholder="请输入时间范围" class="date_pick form-control " id="reservation3" style="width: 200px;">
       	 		<input type="button" class="btn btn-default order_change" value="筛选"/>
       	 	</div>
       	 	<div class=" row box1_lines">
       	 		<div class="col-lg-7 col-md-12 lines_item" id="my_chart3">
       	 		</div>
       	 		<div class="col-lg-5 col-md-12 lines_item lines_text order_changePer">
       	 		</div>
       	 	</div>
       	 </div>
       </div>
    </section>
    <!-- /.content -->
  </div>
   
  <!-- /.content-wrapper -->
  <footer class="main-footer">
    <div class="pull-right hidden-xs">
      <b>Version</b> 2.0.0
    </div>
    <strong>Copyright &copy; 2017-2018 西安寒武纪信息科技有限公司.</strong> All rights
    reserved.
  </footer>
</div>
<script src="js/jquery.min.js"></script>



<script src="js/adminlte.min.js"></script>
<script type="text/javascript" src="js/echarts-all.js" ></script>
<script src="js/macarons.js"></script>
<script type="text/javascript" src="js/moment.min.js" ></script>
<script src="js/bootstrap-datepicker.min.js"></script>
<script src="js/daterangepicker.js"></script>
<script src="js/select2.full.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/layer.js" ></script>
<script type="text/javascript" src="js/jq.cookie.js" ></script>
<script src="js/change_password.js"></script>
<script>
	$(document).ready(function(){
	
	 "use strict"; 
	 $('.select2').select2();
	  $('#reservat').datepicker({
	  	format:'yyyy-mm-dd'
	  });
	   $('#reservat2').datepicker({
	  	format:'yyyy-mm-dd'
	  });
	   $('#reservation3').daterangepicker({
	   	startDate:'2018-11-01',
	  	locale:{
	  		"daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
			"monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
	  		"applyLabel": "确定",
	  		"cancelLabel": "确定",
	  		format:'YYYY-MM-DD'
	  		}
	  });
	   var myChart3 = echarts.init(document.getElementById('my_chart3'),'macarons'); 
   	 var myChart2 = echarts.init(document.getElementById('my_chart2'),'macarons');
   	 var myChart = echarts.init(document.getElementById('my_chart'),'macarons');
	  
	  getData();
	  function getData(){
	      $.ajax({
	      	type:"get",
	      	url:"https://www.retux.cn/MgOrderLog",
	      	async:true,
	      	success:function(data){
	      		if(data.length==0){
				  			layer.msg('暂无数据');
				  		}else{
				  			dataView(data)
				  		}
	      		
	      	}
	      });
     }
	  
	  $('.order_change').click(function(){
	  	 var Time = $('#reservation3').val();
	  	 var start = Time.split(' -')[0];
	    var end = Time.split('- ')[1];
	  		$.ajax({
	  			type:"get",
	  			url:"https://www.retux.cn/MgOrderLogSearch3",
	  			async:true,
	  			data:{
	  				start:start,
	  				end:end
	  			},success:function(data){
	  				if(data.length==0){
				  			layer.msg('暂无数据');
				  		}else{
				  			 order_change(data);
				  		}
	  				
	  			}
	  		});
	  })
	  $('.dayorder_search').click(function(){
	  	    var Time = $('#reservat').val();
	  		$.ajax({
	  			type:"get",
	  			url:"https://www.retux.cn/MgOrderLogSearch1",
	  			async:true,
	  			data:{
	  				Time:Time
	  			},success:function(data){
	  				if(data.length==0){
				  			layer.msg('暂无数据');
				  		}else{
				  			 var sChart1 = [];
			  				 for (var key in data) {
						   	 	sChart1.push(data[key])
						   	 }
			  				 hire_order(sChart1)
				  		}
	  				
	  			}
	  		});
	  })
	   $('.week_order').click(function(){
	  	    var Time = $('#reservat2').val();
	  		$.ajax({
	  			type:"get",
	  			url:"https://www.retux.cn/MgOrderLogSearch2",
	  			async:true,
	  			data:{
	  				Time:Time
	  			},success:function(data){
	  				if(data.length==0){
				  			layer.msg('暂无数据');
				  		}else{
				  			 getWeekDate(data)
				  		}
	  				
	  			}
	  		});
	  })
    function dataView(data){
		//基础数据
		for (var i=0;i<data[0].length;i++) {
			$('.order_status').find('label').eq(i).text(data[0][i])
		}
	
    
   	 var ChartData = [];
   	 for (var key in data[1]) {
   	 	ChartData.push(data[1][key])
   	 }
   	 hire_order(ChartData);
   	 getWeekDate(data[2]);
   	 order_change(data[3]);
   	
	}
    function order_change(data){
    	 var allOrder = 0;
    	 var maxLose = 0;//最大流失点
    	 var maxLoseText='';
	   	 for (var i=0;i<data.length;i++) {
	   	 	allOrder+=data[i];
	   	 	if(i==4){break;}
	   	 	var loseNum = data[i]-data[i+1];
	   	 	if(loseNum>maxLose){
	   	 		maxLose = loseNum;
	   	 		switch (i){
	   	 			case 0:maxLoseText='用户登录'
	   	 				break;
	   	 			case 1:maxLoseText='开通会员'
	   	 				break;
	   	 			case 2:maxLoseText='地址确认'
	   	 				break;
	   	 			case 3:maxLoseText='完成订单'
	   	 				break;
	   	 			default:
	   	 				break;
	   	 		}
	   	 	}
	   	 }
	  
    	var changePersent = (data[4]/allOrder)*100+'%';

		if(changePersent=='NaN%'){
    		changePersent='0%';
    	}
    	var order_changeD = `所选时间段内共有<span>${allOrder}个</span>租赁请求，<br /><br />
       	 			 最终完成订单流程共<span>${data[4]}个</span>，<br /><br />
       	 			 转化率为<span>${changePersent}</span>，最高流失点<a>${maxLoseText}</a>步骤`;
    	
    	
    	$('.order_changePer').html(order_changeD);
   	 
		 myChart3.setOption({
			    tooltip : {
			        trigger: 'axis'
			    },
			    legend: {
			        data:['订单转化']
			    },
			    toolbox: {
			        show : true,
			        feature : {
			            magicType : {show: true, type: ['line', 'bar']},
			            saveAsImage : {show: true}
			        }
			    },
			    calculable : true,
			    xAxis : [
			        {
			            data : ['下单租赁','用户登录','开通会员','地址确认','完成订单']
			        }
			    ],
			    yAxis : [
			        {
			            type : 'value',
			            axisLabel : {
				                formatter: '{value}'
				            }
			        }
			    ],
			    series : [
			        {
			            name:'订单转化',
			            type:'bar',
			            data:data
			            
			        }
			    ]
			    
			});

    }
    function hire_order(data){
    	$('.table_data').html('')
    	
    	var weekNum = ['星期一','星期二','星期三','星期四','星期五','星期六','星期天']
        for (var i=0;i<data.length;i++) {
        	var Tr = `   <tr>
       	 					<td>${weekNum[i]}</td>
       	 					<td>${data[i]}</td>
       	 				</tr>`;
       	 	$('.table_data').append(Tr)
        }
    	 myChart2.setOption({
			    tooltip : {
			        trigger: 'axis'
			    },
			    legend: {
			        data:['租赁订单']
			    },
			    toolbox: {
			        show : true,
			        feature : {
			            magicType : {show: true, type: ['line', 'bar']},
			            saveAsImage : {show: true}
			        }
			    },
			    calculable : true,
			    xAxis : [
			        {
			            data : ['周一','周二','周三','周四','周五','周六','周日']
			        }
			    ],
			    yAxis : [
			        {
			            type : 'value'
			        }
			    ],
			    series : [{
			            name:'租赁订单',
			            type:'line',
			            data:data
			            
			        }
			    ]
			    
			});
    }
   function getWeekDate(data){
   		$('.prev_hire').text(data[1][0]);
	  $('.now_hire').text(data[0][0]);
	  $('.prev_pay').text(data[1][1]);
	  $('.now_pay').text(data[0][1]);
	  $('.hire_change').text(data[2]);
	  $('.pay_change').text(data[3]);
   	   	     myChart.setOption({
			    tooltip : {
			        trigger: 'axis'
			    },
			    legend: {
			        data:['租赁订单','支付订单']
			    },
			    toolbox: {
			        show : true,
			        feature : {
			            magicType : {show: true, type: ['line', 'bar']},
			            saveAsImage : {show: true}
			        }
			    },
			    calculable : true,
			    xAxis : [
			        {
			            data : ['本周','上周']
			        }
			    ],
			    yAxis : [
			        {
			            type : 'value'
			        }
			    ],
			    series : [
			        {
			            name:'租赁订单',
			            type:'bar',
			            data:[data[0][0], data[1][0]]
			            
			        },
			        {
			            name:'支付订单',
			            type:'bar',
			            data:[data[0][1], data[1][1]]
			            
			        }
			    ]
			    
			});
   }
})
</script>	
</body>
</html>
